package scnr;

import bbcom.ScenarioType;
import bbcom.interfaces.IScenarioParser;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Thanh-Trung Pham on 6/21/2016.
 */
public class ScenarioParser implements IScenarioParser {
    @Override
    public List<String> getSortedAllocationNames(ScenarioType scenario, List<String> allAllocationNames) {
        XmlObject[] oScenarioDAGAttributes = scenario.selectPath("$this/@scnr.dag");
        if (oScenarioDAGAttributes != null && oScenarioDAGAttributes.length != 0) {
            String strScenarioDAG = ((XmlAnyTypeImpl) oScenarioDAGAttributes[0]).getStringValue();
            //TODO: Build up a matrix representing a directed graph and then use the topological sorting to obtain the sorted allocation names
        }

        return allAllocationNames;
    }
}
